# Copyright (c) 2023 HPMicro
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.13)

set(CONFIG_SDMMC 1)
set(CONFIG_HPM_SPI_SDCARD 1)
set(CONFIG_HPM_SPI 1)
set(CONFIG_DMA_MGR 1)


# the following lines before "### END ###" are added during project localization
### START ###
set(ENV{HPM_SDK_BASE} "${CMAKE_CURRENT_SOURCE_DIR}/hpm_sdk_localized_for_hpm6750evk")
set(LOCALIZED_BOARD "hpm6750evk")
if(BOARD)
  if(NOT ${BOARD} MATCHES ${LOCALIZED_BOARD})
    message(FATAL_ERROR "ABORT:\n hpm sdk has been localized for ${LOCALIZED_BOARD} already.")
  endif()
endif()
set(BOARD ${LOCALIZED_BOARD})
### END ###


find_package(hpm-sdk REQUIRED HINTS $ENV{HPM_SDK_BASE})

project(spi_sdcard_sample)

sdk_compile_definitions(-DUSE_DMA_TRANSFER=1)
sdk_compile_definitions(-DSPI_SD_LOG=printf)
sdk_compile_definitions(-DSPI_SD_SPEED_MAX_HZ=40000000)

sdk_inc(../common/adapt)

sdk_app_src(../common/adapt/spi_sd_adapt.c)
sdk_app_src(src/spi_sdcard.c)

generate_ide_projects()



